package com.heima.article.task;

import com.heima.article.service.IApArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定时查询热点文章
 *
 * @Author : wuqiang
 * @since : 2022-10-19
 */
@Slf4j
@Component
public class HotApArticleTask {

    @Autowired
    private IApArticleService apArticleService;

    /**
     * 定期扫描
     */
    // @Scheduled(cron = "0 0 1 * * ?")
    @XxlJob("regularlyScanHandle")
    public ReturnT<String> regularlyScan(String param) {
        log.info("开始执行每日文章分值计算任务...");
        try {
            apArticleService.compute();
        } catch (Exception e) {
            e.printStackTrace();
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
